<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../../css/common.css" media="all">
		<style type="text/css">
			.content {
				width: 80%;
				height: 350px;
				overflow-y: scroll;
				padding: 0 10px;
			}

			/*滚动条样式*/
			.content::-webkit-scrollbar {
				width: 4px;
				/*height: 4px;*/
			}

			.content::-webkit-scrollbar-thumb {
				border-radius: 10px;
				-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
				background: rgba(0, 0, 0, 0.2);
			}

			.content::-webkit-scrollbar-track {
				-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
				border-radius: 0;
				background: rgba(0, 0, 0, 0.1);

			}

			h3,
			.h3 {
				font-size: 12px;
				margin: 5px 0px;
				font-weight: 400;
			}
			.layui-timeline-item {
			    position: relative;
			    padding-bottom: 10px;
			}
			.layui-timeline-title {
			    position: relative;
			    margin-bottom: 0px;
			}
			.layui-text {
			    line-height: 22px;
			    font-size: 9px;
			    color: #666;
			}
			.layui-text-notes{
				line-height: 22px;
			    font-size: 15px;
			    color: #f00;
			}
		</style>
	</head>
	<body>
		<div class="layui-fluid reporting_style">
			<div class="layui-row" id="view">

				<button type="button" class="layui-btn layui-btn-normal layui-btn-sm return" style="display: none;">
					<i class="layui-icon layui-icon-return"></i>返回列表
				</button>
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
					<legend>订单详情</legend>
				</fieldset>
				<div class="layui-card">
					<div class="layui-card-body">
						<ul class="layui-timeline" id="layui-timeline">
						</ul>
						<ul class="layui-timeline" id="layui-imageline">
						</ul>
						<div class="layui-row layui-col-space15" id="detail_view"></div>
						<div class="layui-fluid">
							<div class="layui-row" id="view">
								<h3>商品信息</h3>
								<table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/html" id="time_line">
			{{# layui.each(d,function(index,obj){ }}
				<li class="layui-timeline-item">
					<i class="layui-icon layui-timeline-axis"></i>
					<div class="layui-timeline-content layui-text">
						<h3 class="layui-timeline-title">
							{{ obj.addtime ? obj.addtime : '--' }} 
							 <span> {{ String(obj.status) ? '<span class="layui-badge layui-bg-green">' + service_order_show(1,String(obj.status)) + '</span>' : '--' }}<span>
						</h3>
						<p class="layui-text-notes">
							{{  obj.notes ? obj.notes : '' }}
						</p>
					</div>
				</li>
			{{#  }) }}
		</script>
		<script type="text/html" id="image_line">
			{{# layui.each(d,function(index,obj){ }}
				<li class="layui-timeline-item">
					<i class="layui-icon layui-timeline-axis"></i>
					<div class="layui-timeline-content layui-text">
						<p class="layui-text-notes">
							{{ obj.image ? '<img src="'+obj.image+'" width="300" height="300">' : '' }} 
							
							{{  obj.notes ? obj.notes : '' }}
						</p>
					</div>
				</li>
			{{#  }) }}
		</script>
		<script type="text/html" id="demo">
			<div class="layui-card">
				<div class="layui-card-body">
					<div class="layui-row details">
						<div class="layui-col-md4">
							订单编号：<span> {{ d.data.orderid ? d.data.orderid : '--' }}<span> 
						</div>
						<div class="layui-col-md4">
							会员编号：<span> {{ d.data.memberid ? d.data.memberid : '--' }}<span> 
						</div>
						<div class="layui-col-md4">
							订单状态： <span> {{ String(d.data.status) ? '<span class="text_red_color">' + service_order_show(1,String(d.data.status)) + '</span>' : '--' }}<span> 
							<button data-method="notice" value="{{d.data.orderid}}" class="layui-btn layui-btn-normal audit_btn" id="button">修改订单状态</button>
						</div>
						
						<div class="layui-col-md4">
							购买数量： <span> {{ d.data.quantity ? d.data.quantity : '--' }}<span> 
						</div>
						<div class="layui-col-md4">
							订单金额： <span> {{ d.data.pay_price ? d.data.pay_price : '--' }}<span> 
						</div>
						
						<div class="layui-col-md4">
							订单类型：<span> {{ String(d.data.type) ? '<span class="text_red_color">' + goods_type_show(1,d.data.type) + '</span>' : '--' }}<span>
								<button data-method="notice_type" value="{{d.data.orderid}}" class="layui-btn layui-btn-normal audit_btn" id="button">修改订单类型</button>
						</div>
						
						<div class="layui-col-md4">
							添加时间： <span> {{ d.data.addtime ? d.data.addtime : '--'}}<span> 
						</div>
					</div>
				</div>
				 
				<div class="layui-card-body">
					<div class="layui-row details">
						{{# layui.each(d.data.orders_fee,function(index,o){ }} 
						
							{{# if(o.type == 'master' ){ }}
								<div class="layui-col-md3">
								 	师傅佣金： <span> {{ o.recommend_fee ? o.recommend_fee   : '--' }}<span> 
								 </div>
							{{# } }}
							{{# if(o.type == 'super' ){ }}
								<div class="layui-col-md3">
								 	上上级佣金： <span> {{ o.recommend_fee ? o.recommend_fee : '--' }}<span> 
								</div>
							{{# } }}
							{{# if(o.type == 'parent' ){ }}
								<div class="layui-col-md3">
								 	上级佣金： <span> {{ o.recommend_fee ? o.recommend_fee : '--' }}<span> 
								</div>
							{{# } }} 
						{{# })}}
					</div>
				</div>
			</div>
			
			<div class="layui-card">
				<div class="layui-card-body">
					<div class="layui-row details">
						<div class="layui-col-md6">
							收货人姓名：<span>{{ d.data.consignee ? d.data.consignee : '--' }}<span> 
						</div>
						<div class="layui-col-md6">
							服务日期：<span>{{ d.data.serve_dates ? d.data.serve_dates : '--' }}<span> 
						</div>
						<div class="layui-col-md6">
							收货人电话：<span>{{ d.data.mobile ? d.data.mobile : '--' }}<span> 
						</div>
						
						
						<div class="layui-col-md6">
							服务时间：<span>{{ d.data.server_times ? d.data.server_times : '--' }}<span> 
						</div>
						<div class="layui-col-xs6">
							收货地址：<span>{{ d.data.areaname ? d.data.areaname : '--' }}{{ d.data.address ? d.data.address : '--' }}<span> 
							<button type="button" data-method="address"  class="layui-btn layui-btn-normal audit_btn" id="address">修改收货信息</button>
						</div>
						
						
						{{# layui.each(d.data.member,function(index,o){ }}
						<div class="layui-col-xs6">
							师傅信息：
							<span> 
								<span> {{ o ? String(o.name?o.name : '')+ o.mobile   : '--' }}<span>   
							<span> 
							
							{{# if(d.data.status!=0 &&d.data.status!=70 ){ }}
							<button type="button" data-method="forward"  class="layui-btn layui-btn-normal audit_btn" id="address">更换师傅</button>
							{{# } }}
							</div>
						{{# })}}
						
					</div>
				</div>
			</div>
		</script>

		<script src="../../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../../js/jquery.min.js"></script>
		<script src="../../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../../js/common.js"></script>
		<script>
			var _data = {
				orderid: getParam('orderid'),
				from : getParam("from")
			}
			// console.log(_data.id);
			if(_data.from){
				$(".return").show()
			}
			layui.config({
				base: '../../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'table'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					table = layui.table,
					form = layui.form;

				initdata();

				function initdata() {
					$.get(server.server_order_detail, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var data = res.orders
								var getTpl = demo.innerHTML,
									view = document.getElementById('detail_view');
								laytpl(getTpl).render(data, function(html) {
									view.innerHTML = html;
								});
								//时间线
								var timeline = time_line.innerHTML,
									view = document.getElementById('layui-timeline')
								laytpl(timeline).render(data.data.orders_oplog, function(html) {
									view.innerHTML = html;
								});
								
								//时间线
								var imageline = image_line.innerHTML,
									view = document.getElementById('layui-imageline')
								laytpl(imageline).render(data.data.orders_image, function(html) {
									view.innerHTML = html;
								});

								//渲染商品信息表格（商品信息集合）
								initData_table(data.data.sub_orders)
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}

				function initData_table(data) {
					table.render({
						elem: '#test-table-operate',
						cellMinWidth: cellMinWidth,
						limit: limit,
						limits: limits,
						data: data,
						cols: [
							[{
									width: 50,
									field: 'zizeng',
									title: '#',
									fixed: 'left',
									templet: '#zizeng'
								}, {
									field: 'skuname',
									title: '商品名称'
								}, {
									field: 'skuid',
									title: '商品编号'
								},
								{
									field: 'specname',
									title: '规格名称'
								},
								{
									field: 'specparam',
									title: '规格参数'
								},
								{
									field: 'memberid',
									title: '会员编号',
									sort: true
								},{
									field: 'price_member',
									title: '会员价',
									sort: true,
								},{
									field: 'price_cost',
									title: '成本价',
									sort: true,
								}, {
									field: 'quantity',
									title: '数量',
									sort: true
								}, {
									field: 'amount_price',
									title: '商品金额',
									sort: true,
								}, {
									field: 'addtime',
									title: '创建时间',
								}
							]
						]
					});
				}
				//给服务修改按钮添加事件
				var active = {
					notice: function(orderid) { //修改服务状态
						console.log(orderid)
						layer.open({
							type: 2,
							title: '修改订单状态',
							shadeClose: false,
							shade: 0.5,
							area: ['40%', '60%'],
							content: 'order_status_edit.html?orderid=' + orderid,
							end: function() {
								location.reload()
							}
						});
					},
					notice_type: function(orderid) { //修改服务状态
						console.log(orderid)
						layer.open({
							type: 2,
							title: '修改订单类型',
							shadeClose: false,
							shade: 0.5,
							area: ['40%', '60%'],
							content: 'order_type_edit.html?orderid=' + orderid,
							end: function() {
								location.reload()
							}
						});
					},
					address:function(){//修改收获地址
						layer.open({
							type: 2,
							title: '修改收货信息',
							shadeClose: false,
							shade: 0.5,
							area: ['50%', '80%'],
							content: 'edit_add.html?orderid=' + _data.orderid,
							end: function() {
								location.reload()
							}
						}); 
					},
					forward:function(){//修改服务师傅
						layer.open({
							type: 2,
							title: '更换师傅',
							shadeClose: false,
							shade: 0.5,
							area: ['50%', '80%'],
							content: 'order_forward.html?orderid=' + _data.orderid,
							end: function() {
								location.reload()
							}
						}); 
					},
				};
				
				 $(document).on('click', '.audit_btn', function() {
					var othis = $(this),
					method = othis.data('method');
					active[method] ? active[method].call(this, othis.attr("value")) : '';
					
				});
			});
			//给类样式 .return 添加的回退功能
			$('.return').on('click', function() {
				window.history.back(-1);
			})
		</script>
	</body>
</html>
